# encoding: utf-8
module SinatraDemo
  module Routes
    class Albums < Base
      set :views, 'app/views/albums'
      get '/albums/new' do
        # @album = Album.new
        @artists = Artist.all
        erb :new
      end
      get '/albums/:id' do
        @album = Album.find(:id=>params[:id])
        erb :show
      end
      get '/albums' do
        @albums = Album.all
        erb :index
      end
      post '/albums' do
        album = Album.create params
        redirect to("/albums/#{album.id}")
      end
    end
  end
end